/*
 * Copyright (c) 2006-2019, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2019-09-09     RT-Thread    first version
 */
#include <rtthread.h>

// #include <mpu9250/mpu9250.h>
// #include <oled/oled.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG

// /* PLEASE DEFINE the LED0 pin for your board, such as: PA5 */
// #define LED0_PIN    GET_PIN(B, 1)

// #define PWM_DEV_NAME        "pwm3"  /* PWM设备名称 */
// #define PWM_DEV_CHANNEL     4       /* PWM通道 */
// struct rt_device_pwm *pwm_dev; /* PWM设备句柄 */

// void mpu_fun(void *param) {
// 	short aacx, aacy, aacz;           	//加速度传感器原始数据
// 	short gyrox, gyroy, gyroz;        	//陀螺仪原始数据
// 	short temp;                     	//温度

// 	/* set LED0 pin mode to output */
// 	rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);

// 	if (MPU9250_Init()) { // 初始化MPU9250
// 		LOG_D("mpu9250 init failed!");
// 		return;
// 	}

// 	LOG_D("mpu9250 init successed");

// 	while (1) {

// 		temp = MPU_Get_Temperature(); //得到温度值
// 		rt_kprintf("temp: %d\n", temp);

// 		MPU_Get_Accelerometer(&aacx, &aacy, &aacz);   //得到加速度传感器数据
// 		rt_kprintf("aacx:%d, aacy: %d, aacz:%d\n", aacx, aacy, aacz);

// 		MPU_Get_Gyroscope(&gyrox, &gyroy, &gyroz);    //得到陀螺仪数据
// 		rt_kprintf("gyrox:%d, gyroy: %d, gyroz:%d\n", gyrox, gyroy, gyroz);

// 		rt_thread_mdelay(1000);
// 	}
// }

// void bme280_fun() {

// 	struct rt_i2c_bus_device *i2c_bus =
// 			(struct rt_i2c_bus_device*) rt_device_find("i2c2");

// 	if (i2c_bus == RT_NULL) {
// 		rt_kprintf("can't find 'i2c2' device\n");
// 	}

// 	rt_uint8_t reg = 0xd0;

// 	rt_uint8_t data;

// 	struct rt_i2c_msg msgs[2] = { { 0x76, RT_I2C_WR, 1, &reg }, { 0x76,
// 	RT_I2C_RD, 1, &data } };

// 	rt_size_t ret = rt_i2c_transfer(i2c_bus, msgs, 2);

// 	if (ret < 0) {
// 		rt_kprintf("i2c transfer failed, ret: %d\n", ret);
// 		return;
// 	}

// 	rt_kprintf("data: 0x%x\n", data);
// }

// void test_pwm(void) {

// 	rt_uint32_t period = 500000; /* 周期为0.5ms，单位为纳秒ns */
// 	rt_uint32_t pulse = 0; /* PWM脉冲宽度值，单位为纳秒ns */

// 	/* 查找设备 */
// 	pwm_dev = (struct rt_device_pwm *) rt_device_find(PWM_DEV_NAME);

// 	if (pwm_dev == RT_NULL) {
// 		rt_kprintf("pwm run failed! can't find %s device!\n",
// 		PWM_DEV_NAME);
// 		return;
// 	}

// 	/* 设置PWM周期和脉冲宽度 */
// 	rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, period, pulse);
// }



int main(void) {

	// run_oled();

//	test_pwm();
//
//	bme280_fun();
//	oled_fun();

	// while (1) {
	// 	LOG_I("hello\n");
	// 	rt_thread_mdelay(2000);
	// }

	return RT_EOK;
}
